package com.xique.park.controller.auto;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xique.common.log.annotation.Log;
import com.xique.common.log.enums.BusinessType;
import com.xique.common.security.annotation.PreAuthorize;
import com.xique.park.bean.domain.ParkPayConf;
import com.xique.park.service.service.IParkPayConfService;
import com.xique.common.core.web.controller.BaseController;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.common.core.utils.poi.ExcelUtil;
import com.xique.common.core.web.page.TableDataInfo;

/**
 * 车场支付配置Controller
 * 
 * @author xique
 * @date 2021-12-09
 */
@RestController
@RequestMapping("/payConf")
public class ParkPayConfController extends BaseController
{
    @Autowired
    private IParkPayConfService parkPayConfService;

    /**
     * 查询车场支付配置列表
     */
    @PreAuthorize(hasPermi = "park:conf:list")
    @GetMapping("/list")
    public TableDataInfo list(ParkPayConf parkPayConf)
    {
        startPage();
        List<ParkPayConf> list = parkPayConfService.selectParkPayConfList(parkPayConf);
        return getDataTable(list);
    }

    /**
     * 导出车场支付配置列表
     */
    @PreAuthorize(hasPermi = "park:conf:export")
    @Log(title = "车场支付配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkPayConf parkPayConf) throws IOException
    {
        List<ParkPayConf> list = parkPayConfService.selectParkPayConfList(parkPayConf);
        ExcelUtil<ParkPayConf> util = new ExcelUtil<ParkPayConf>(ParkPayConf.class);
        util.exportExcel(response, list, "车场支付配置数据");
    }

    /**
     * 获取车场支付配置详细信息
     */
    @PreAuthorize(hasPermi = "park:conf:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(parkPayConfService.selectParkPayConfById(id));
    }

    /**
     * 新增车场支付配置
     */
    @PreAuthorize(hasPermi = "park:conf:add")
    @Log(title = "车场支付配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkPayConf parkPayConf)
    {
        return toAjax(parkPayConfService.insertParkPayConf(parkPayConf));
    }

    /**
     * 修改车场支付配置
     */
    @PreAuthorize(hasPermi = "park:conf:edit")
    @Log(title = "车场支付配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkPayConf parkPayConf)
    {
        return toAjax(parkPayConfService.updateParkPayConf(parkPayConf));
    }

    /**
     * 删除车场支付配置
     */
    @PreAuthorize(hasPermi = "park:conf:remove")
    @Log(title = "车场支付配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(parkPayConfService.deleteParkPayConfByIds(ids));
    }
}
